<?php

namespace Biz\Models\App;

use Biz\Models\Model;

/**
 * Site.
 *
 * @license [http://www.85do.com] [杭州永奥网络科技有限公司]
 * @copyright Copyright (c) 2018-2026 Hangzhou Yongao Technology Co., Ltd. All rights reserved.
 */
class AppSite extends Model
{
    /**
     * The table associated with the model.
     *
     * @var string
     */
    protected $table = 'app_site';

    /**
     * @var array
     */
    protected $fillable = [
        'app_id',
        'name',
        'domain',
        'description',
    ];

    /**
     * App.
     *
     * @var App
     */
    private $app;

    /**
     * @return App
     */
    public function getApp()
    {
        return $this->app;
    }

    /**
     * @param App $app
     */
    public function setApp(App $app)
    {
        $this->app = $app;
    }

    /**
     * 查询App.
     */
    public function app()
    {
        //return $this->hasOne(App::class, 'id', 'app_id');
        return $this->belongsTo(App::class, 'app_id', 'id');
    }

    /**
     * 支持的语言列表.
     *
     * @return \Illuminate\Database\Eloquent\Relations\HasMany
     */
    public function languages()
    {
        return $this->hasMany(AppSiteLanguage::class, 'site_id');
    }
}
